home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Windows 95 API Bible
/
Windows 95 API Bible 3 Disc Set.iso
/
Win32 API Bible Book 1 of 3
/
CHAPTE19
/
EX4.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-05-14
|
2KB
|
79 lines
// reg ex4.c
#include <windows.h>
#include <winreg.h>
#include <genstub.c>
DWORD WINAPI ChildThreadProc( LPTSTR lpszBuffer )
{
HKEY hKey = 0;
LONG lErr = RegOpenKeyEx( HKEY_CLASSES_ROOT, "Flush", 0, KEY_ALL_ACCESS, &hKey );
if ( lErr==ERROR_SUCCESS ) {
lstrcpy( lpszBuffer, "Got Key From Registry!" );
RegCloseKey( hKey );
}
else
lstrcpy( lpszBuffer, " No Key From Registry! " );
ExitThread( 1 );
}
LRESULT FAR PASCAL WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
switch( uMsg )
{
case WM_COMMAND: // process menu items
switch( wParam )
{
case IDM_TEST: {
TCHAR szBuffer[128];
DWORD dwChildId;
DWORD dwDisposition;
HANDLE hChildThread;
HKEY hKey;
RegCreateKeyEx( HKEY_CLASSES_ROOT, "Flush", 0, "MyClass",
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
NULL, &hKey, &dwDisposition );
// RegFlushKey( hKey );
hChildThread = CreateThread( NULL, 0, ChildThreadProc,
szBuffer, 0, &dwChildId );
WaitForSingleObject( hChildThread, INFINITE );
MessageBox( hWnd, szBuffer, "Flush Key Test", MB_OK );
RegDeleteKey( HKEY_CLASSES_ROOT, "FlushTest" );
}
break;
case IDM_EXIT:
DestroyWindow( hWnd );
break;
}
break;
case WM_DESTROY:
PostQuitMessage( 0 );
break;
default:
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
return( 0L );
}